package com.lck.tutor.utils;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;

class Base
{
    static String s;
    public Base(int a) {
        System.out.println(a);
    }
    public static void main (String[] args){
        System.out.println("s=" + s);
    }
//    public void method()
//    {
//        this(1);
//        System.out.println("Base");
//    }
}
//class Son extends Base
//{
//    public void method()
//    {
//        System.out.println("Son");
//    }
//
//    public void methodB()
//    {
//
//    }
//}
public class Test01
{
    public static void main(String[] args) throws InterruptedException {
        ThreadPoolExecutor newFixedThreadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(2);
        ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
        List<Future<String>> futures = newFixedThreadPool.invokeAll(Arrays.asList(
                () -> {
                    System.out.println(Thread.currentThread().getName());
                    return "1";
                },
                () -> {
                    System.out.println(Thread.currentThread().getName());
                    return "2";
                },
                () -> {
                    System.out.println(Thread.currentThread().getName());
                    return "3";
                }
        ));
        futures.forEach(f ->{
            try {
                System.out.println(f.get());
            } catch (InterruptedException | ExecutionException e) {
                e.printStackTrace();
            }
        });
    }
}